package com.ww.springboot.boot.thread.study.base.interrupt;

import com.ww.springboot.boot.thread.study.base.lock.aqs.util.ThreadPrintUtil;

import java.util.concurrent.locks.LockSupport;

/**
 * 描述：
 * 中断可以唤醒阻塞!!!
 *
 * 如果线程是正常运行过程中被中断 则线程不能恢复
 * 如果线程是因为LockSupport被中断 则可以在中断的位置park()处恢复
 *
 * @author 🧑 ‍wanwei
 * @since 2023-03-17 16:24
 */
public class InterruptDemo7 {

    public static void main(String[] args) throws InterruptedException {

        Thread thread = new Thread(() -> {
            ThreadPrintUtil.sout("开始");
            LockSupport.park();
            ThreadPrintUtil.sout("解锁");
        });
        thread.start();

        Thread.sleep(1000);
        System.out.println(thread.isInterrupted());
        thread.interrupt();
        System.out.println(thread.isInterrupted());
    }
}
